<% layout('/layouts/default.html', {title: '项目信息管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('项目信息管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('hl_project:ajzProjectInfo:edit')){ %>
				<a href="${ctx}/hl_project/ajzProjectInfo/form" class="btn btn-default btnTool" title="${text('新增项目信息')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						<i class="fa fa-navicon"></i> <span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" id="btnImport"><i class="glyphicon glyphicon-import"></i> 导入</a></li>
						<li><a href="javascript:" id="btnExport"><i class="glyphicon glyphicon-export"></i> 导出</a></li>
					</ul>
				</div>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${ajzProjectInfo}" action="${ctx}/hl_project/ajzProjectInfo/listData" method="post" class="form-inline"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('项目名称')}：</label>
					<div class="control-inline">
						<#form:input path="projectName" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('项目类别')}：</label>
					<div class="control-inline width-120">
						<#form:select path="projectType" dictType="project_type" blankOption="true" class="form-control"/>
					</div>
				</div>

				<div class="form-group">
					<label class="control-label">${text('所在街道')}：</label>
					<div class="control-inline width-120">
						<#form:select path="street" dictType="hlq_street" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('责任单位')}：</label>
					<div class="control-inline">
						<#form:input path="dutyUnit" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('责任联系人')}：</label>
					<div class="control-inline">
						<#form:input path="joinContactPerson" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
	// 初始化DataGrid对象
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'${text('项目名称')}', name:'projectName', index:'a.project_name', width:150, align:"left" ,frozen:true, formatter: function(val, obj, row, act){
				return '<a href="${ctx}/hl_project/ajzProjectInfo/form1?id='+row.id+'&isNotEdit=1" class="btnList" data-title="${text('查看项目信息')}">'+(val||row.id)+'</a>';
			}},
			{header:'${text('项目类别')}', name:'projectType', index:'a.project_type', width:150, align:"left" ,formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('project_type')}, val, '${text('未知')}', true);
			}},
			{header:'${text('所在街道')}', name:'street', index:'a.street', width:150, align:"center", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('hlq_street')}, val, '${text('未知')}', true);
			}},
			{header:'${text('地址')}', name:'address', index:'a.address', width:150, align:"left"},
//		{header:'${text('法人')}', name:'legalPerson', index:'a.legal_person', width:150, align:"left"},
//			{header:'${text('项目联系人')}', name:'contactPerson', index:'a.contact_person', width:150, align:"left"},
		{header:'${text('责任联系人')}', name:'joinContactPerson', index:'a.join_contact_person', width:150, align:"left"},
		{header:'${text('责任人电话：')}', name:'joinContactPersonTel', index:'a.join_contact_person_tel', width:150, align:"left"},
			{header:'${text('创建时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
			{header:'${text('状态')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);
			}},
			{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
				var actions = [];
				<% if(hasPermi('hl_project:ajzProjectInfo:edit')){ %>
				actions.push('<a href="${ctx}/hl_project/ajzProjectInfo/form?id='+row.id+'" class="btnList" title="${text('编辑项目信息')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/hl_project/ajzProjectInfo/delete?id='+row.id+'" class="btnList" title="${text('删除项目信息')}" data-confirm="${text('确认要删除该项目信息吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
				<% } %>
				return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});


	$('#btnExport').click(function(){
		js.ajaxSubmitForm($('#searchForm'), {
			url:'${ctx}/hl_project/ajzProjectInfo/exportData',
			downloadFile:true
		});
	});
	$('#btnImport').click(function(){
		js.layer.open({
			type: 1,
			area: ['400px'],
			title: '导入用户数据',
			resize: false,
			scrollbar: true,
			content: js.template('importTpl'),
			success: function(layero, index){
				layero.find('input[type="checkbox"]').iCheck();
			},
			btn: ['<i class="fa fa-check"></i> 导入',
				'<i class="fa fa-remove"></i> 取消'],
			btn1: function(index, layero){
				var form = {
					inputForm: layero.find('#inputForm'),
					file: layero.find('#file').val()
				};
				if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
					js.showMessage("${text('文件不正确，请选择后缀为 “xls”或“xlsx”的文件。')}", null, 'warning');
					return false;
				}
				js.ajaxSubmitForm(form.inputForm, function(data){
					js.showMessage(data.message);
					if(data.result == Global.TRUE){
						js.layer.closeAll();
					}
					page();
				}, "json");
				return true;
			}
		});
	});

</script>
<script id="importTpl" type="text/template">//<!--
<form id="inputForm" action="${ctx}/hl_project/ajzProjectInfo/importData" method="post" enctype="multipart/form-data" class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
	<div class="row">
		<div class="col-xs-12 col-xs-offset-1">
			<input type="file" id="file" name="file" class="form-file"/>
			<div class="mt10 pt5">
				<#form:checkbox name="updateSupport" label="${text('是否更新已经存在的用户数据')}" class="form-control"
					title="${text('如果用户编码已经存在，更新这条数据。')}"/> &nbsp;
				<a href="${ctx}/hl_project/ajzProjectInfo/importTemplate" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> ${text('下载模板')}</a>
			</div>
			<font color="red" class="pull-left mt10">
				${text('提示：仅允许导入“xls”或“xlsx”格式文件！')}
			</font>
		</div>
	</div>
</form>
//-->
</script>